home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / Tele / Pete Johnson / Mehit 3.0.b15<source>.sit / LogUtils.p < prev    next >
Encoding:
Text File  |  1991-06-22  |  1.7 KB  |  65 lines  |  [TEXT/PJMM]

  1. unit LogUtils;
  2.  
  3. interface
  4.  
  5. uses
  6.     Globals;
  7.  
  8. procedure TimeStamp;
  9.  
  10. function Int2Char (Number: integer): char;
  11.  
  12. implementation
  13.  
  14. { ------------------------------------------------------ }
  15.  
  16.  
  17. function Int2Char;{ (Number: integer): char}
  18.  
  19. { Function changes integer to character.                                }
  20.  
  21.     begin
  22.         Int2Char := chr(Number + ord('0'));
  23.     end;
  24.  
  25. { ------------------------------------------------------ }
  26.  
  27. function TwoDigit (Number: integer): string;
  28.  
  29. { Function changes two-digit number to a two-character string.           }
  30.  
  31.     begin
  32.         TwoDigit := concat(Int2Char(Number div 10), Int2Char(Number mod 10));
  33.     end;
  34.  
  35. { ------------------------------------------------------ }
  36.  
  37. procedure TimeStamp;
  38.  
  39.     var
  40.         Today: DateTimeRec;
  41.         ASCIIHour: string;
  42.  
  43.     begin
  44.         GetTime(Today);
  45.  
  46. { The TwoDigit function in the following section turns a two-digit integer          }
  47. { into a two-character string. If there are fewer than two digits, the string    }
  48. { contains a leading '0'.                                                                              }
  49.  
  50.         with Today do
  51.             begin
  52.                 ASCIIHour := TwoDigit(Hour);                {    This bit of nonsense is to get the Tabby Log output        }
  53.                 if length(ASCIIHour) > 1 then                    {    to match a Tabby convention: single-digit hours do        }
  54.                     if (copy(ASCIIHour, 1, 1) = '0') then        {    not have leading zeroes, even though all other single        }
  55.                         ASCIIHour := copy(ASCIIHour, 2, 1);        {    digit numbers do.                                                }
  56.  
  57.                 DateString := concat(TwoDigit(Month), '/', TwoDigit(Day), '/', TwoDigit(Year - 1900));
  58.                 TimeString := concat(ASCIIHour, ':', TwoDigit(Minute), ':', TwoDigit(Second));
  59.                 DateString := concat(DateString, ' ', TimeString);
  60.             end;
  61.     end;
  62.  
  63. { ------------------------------------------------------ }
  64.  
  65. end.